package com.nbjtjc.safe.mapper.edu;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.nbjtjc.safe.model.edu.EduDailyParticipant;
import com.nbjtjc.safe.model.edu.EduDailyRecord;
import com.nbjtjc.util.MyMapper;
@Mapper
public interface EduDailyRecordMapper extends MyMapper<EduDailyRecord> {
//	@Select("select * from edu_daily_record where info_id = #{infoId}")
	EduDailyRecord findByInfoId(@Param("infoId") int infoId);
	
	EduDailyRecord findDetailByInfoId(@Param("infoId") int infoId);

//	@Select("select * from edu_daily_record where info_id =#{i}")
//	EduDailyRecord findByInfoId2(@Param("i") int infoId);
	
	List<EduDailyRecord> search(@Param("edr")EduDailyRecord eduDailyRecord);
	
	List<EduDailyRecord> searchDetail(@Param("edr")EduDailyRecord eduDailyRecord);
	
	@Insert("INSERT INTO edu_daily_record (`info_id`,`cancel`) VALUE (#{infoId},0)")
	int createByInfoId(@Param("infoId") int infoId);
	
	@Update("UPDATE edu_daily_record set participants_count = (SELECT SUM(participate) FROM edu_daily_participant WHERE  edu_daily_info_id = #{edr.infoId})")
	int updatePartCount(@Param("edr")EduDailyRecord eduDailyRecord);
	
	@Update("update edu_daily_record set cancel = 1 where info_id = #{infoId}")
	int cancelByInfoId(@Param("infoId") int infoId);
}